package com.lbs.view.adapter;

import java.util.ArrayList;

import com.lbs.droiddoctor.R;

import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

public class SymptomListAdapter extends BaseAdapter {

	private Context ctx;
	
	private Handler uiHandler;
	private ArrayList<String> symptoms;

	public SymptomListAdapter(Context ctx, ArrayList<String> symptoms,Handler uiHandler) {
		this.ctx = ctx;
		this.uiHandler = uiHandler;
		this.symptoms = symptoms;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return symptoms.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup arg2) {
		// TODO Auto-generated method stub
		View v = null;
		
		if (convertView != null) {
			v = convertView;
		} else {
			LayoutInflater inflater = LayoutInflater.from(ctx);
			v = inflater.inflate(R.layout.symptom_text, null);
		}
		TextView tv = (TextView) v.findViewById(R.id.symptomtext);
		ImageView iv = (ImageView) v.findViewById(R.id.search_icon);
		final int selPosition = position;
		iv.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				Message msg = new Message();
				msg.what = 1;
				msg.arg1 = selPosition;
				uiHandler.dispatchMessage(msg);
				
			}
		});
		
			tv.setText("   " + symptoms.get(position));
		
		return v;
	}

}
